<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form action="./login.html" method="get">
    <p>
      <label for="">用户名:</label><input name="user" type="text">
    </p>
    <p>
      <label for="">密&emsp;码:</label><input name="pwd" type="text">
    </p>
    <p>
      <label for="">手机号:</label><input name="phone" type="text">
    </p>
    <p>
      <label for="">邮&emsp;箱:</label><input name="email" type="text">
    </p>
    <input class="btn" type="submit" value="提交" />
  </form>
</body>
<script>
  // 1.  注册页(输入数据)  => 跳转至登录   (注册页主要为了提供数据   直接打开登录 没有数据)
  // 2.  登录页 从url中获取传递的数据  =>解析成一个对象 {user,pwd,phone,email} 

  // 数据拆分(解析)
  // http://127.0.0.1:5500/day12/html/login.html?user=a123123&pwd=123123&phone=17386141517&email=1272071495%40qq.com

  // user=a123123&pwd=123123&phone=17386141517&email=1272071495%40qq.com

  // var data = {
  //     "user": "a123123",
  //     pwd: 123123
  //     phone: 123123
  //     email: 123123
  // }
  var userInp = document.querySelector('.user')
  var pwdInp = document.querySelector('.pwd')
  var phoneInp = document.querySelector('.phone')
  var emailInp = document.querySelector('.email')
  var btn = document.querySelector('.btn')
  btn.onclick = function () {
    var user = userInp.value;
    var pwd = pwdInp.value;
    var phone = phoneInp.value;
    var email = emailInp.value;
    //  login.html?user=222&pwd=333&phone=4444&email=5555
    if (user && pwd && phone && email) {
      location.href = ".login.html?user=" + user + "pwd=" + pwd + "phone=" + phone + "email=" + email;
    }
  }


</script>

</html>